//
//  ZJSettingViewController.swift
//  mini
//
//  Created by Mac on 2017/5/22.
//  Copyright © 2017年 Mac. All rights reserved.
//

import UIKit

class ZJSettingViewController: UIViewController {
    
    var allData:NSArray = ["意见反馈","服务协议"]
    
    var tableView:UITableView?

    override func viewDidLoad() {
        super.viewDidLoad()
        setSettingVc()
        // Do any additional setup after loading the view.
    }
 
    func setSettingVc()  {
        
        title = "设置"
        view.backgroundColor = kGlobelBgColor
        self.automaticallyAdjustsScrollViewInsets = false
        tableView = UITableView(frame: CGRect(x: 0, y: 20+(self.navigationController?.navigationBar.height)!, width: ScreenWidth, height: 42*2+100))
        tableView?.delegate = self
        tableView?.dataSource = self
        tableView?.backgroundColor = kGlobelBgColor
        tableView?.showsVerticalScrollIndicator = false
        tableView?.showsHorizontalScrollIndicator = false
        tableView?.bounces = false
        tableView?.tableFooterView = UIView()
        tableView?.isScrollEnabled = false
        view.addSubview(tableView!)
        navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named:"YC_Nav_Back"), style: .plain, target: self, action: #selector(self.back))

        
        
    }
    func back()  {
        
        
        dismiss(animated: true) { 
            
        }
        
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

}

extension ZJSettingViewController:UITableViewDelegate,UITableViewDataSource{
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return allData.count
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cellId :String = "ZJSettingViewController"
        var cell = tableView.dequeueReusableCell(withIdentifier: cellId)
        if cell==nil {
            cell = UITableViewCell(style: .default, reuseIdentifier: cellId)
        }
        cell?.textLabel?.text = allData[indexPath.row] as? String
        cell?.accessoryType = .disclosureIndicator
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
       return  44
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        tableView.deselectRow(at: indexPath, animated: true)
        
        if indexPath.row==0{
            
            navigationController?.pushViewController(ZJFedeBackViewController(), animated: true)
            
        }else if indexPath.row==1{
            
            let pvc:ZJProtocolViewController = ZJProtocolViewController()
            
            pvc.url = "http://wx-heartorg.yk2020.com/weixin/Application/Member/View/app/yonghuxieyi.html"
            
             navigationController?.pushViewController(pvc, animated: true)
            
        }else{
            
        }
        
        
    }
    
}
